package cn.gailvlun.gll.presentation.wish.drawer;

import android.content.Context;
import android.content.Intent;
import android.databinding.DataBindingUtil;
import android.os.Bundle;
import android.support.annotation.Nullable;

import java.util.Date;

import cn.gailvlun.gll.Constants;
import cn.gailvlun.gll.R;
import cn.gailvlun.gll.databinding.ActivityCommentDetailBinding;
import cn.gailvlun.gll.net.base.Profile;
import cn.gailvlun.gll.net.wish.Wish;
import cn.gailvlun.gll.net.wish.WishCropped;
import cn.gailvlun.gll.presentation.base.BaseActivity;
import cn.gailvlun.gll.widget.NavigationBarView;


public class CommentDetailActivity extends BaseActivity {

    private ActivityCommentDetailBinding mBinding;


    public static void openActivity(Context context, Wish item) {
        Intent intent = new Intent(context, CommentDetailActivity.class);

        WishCropped wishCropped = new WishCropped();

        int wishId = item.getId();
        int validity = item.getDay_num();
        Date DateCreated = item.getCreated();
        String acceptedDatetime = item.getAccepted_datetime();
        String wishText = item.getText();

        Profile owner = item.getOwner();
        String ownerAvatar = owner.getAvatar();
        String ownerName = owner.getName();
        String ownerBirthday = owner.getBirthday();
        String ownerCommentText = item.getOwner_comment_text();
        int ownerCommentScore = item.getOwner_comment_score();
        Date ownerCommentDatetime = item.getOwner_comment_datetime();

        Profile accepter = item.getAccepter();
        String accepterAvatar = accepter.getAvatar();
        String accepterName = accepter.getName();
        String accepterBirthday = accepter.getBirthday();
        int accepterCommentScore = item.getAccepter_comment_score();
        String accepterCommentText = item.getAccepter_comment_text();
        Date accepterCommentDatetime = item.getAccepter_comment_datetime();

        wishCropped.setWishText(wishText)
                .setOwnerAvater(ownerAvatar)
                .setOwnerName(ownerName)
                .setOwnerCommentText(ownerCommentText)
                .setOwnerCommentDatetime(ownerCommentDatetime)
                .setOwnerCommentScore(ownerCommentScore)
                .setAccepterAvatar(accepterAvatar)
                .setAccepterName(accepterName)
                .setAccepterCommentText(accepterCommentText)
                .setAccepterCommentDatetime(accepterCommentDatetime)
                .setAccepterCommentScore(accepterCommentScore);

        intent.putExtra(Constants.EXTRA_WISH_OBJ, wishCropped);
        context.startActivity(intent);

    }

    @Override
    protected void initComponent() {
        mBinding = DataBindingUtil.setContentView(mContext, R.layout.activity_comment_detail);
        WishCropped wish = (WishCropped) getIntent().getParcelableExtra(Constants.EXTRA_WISH_OBJ);
        mBinding.setWish(wish);
    }

    @Override
    protected void createHandler() {
        mBinding.navigationBar.setOnBackListener(new NavigationBarView.OnBackListener() {
            @Override
            public void onBack(NavigationBarView nb) {
                onBackPressed();
            }
        });
    }

    @Override
    protected void loadData(@Nullable Bundle savedInstanceState) {
    }

}
